package com.iceengine.j3d.camera;

/**
 * Basic camera controler
 * @author penguin
 */
import com.iceengine.input.keyboard.IKeyboardEvent;
import com.iceengine.input.mouse.IMouseEvent;
public class BasicCameraControl implements ICameraControl, IKeyboardEvent, IMouseEvent {
    private int[] keysToWaitFor = {17, 31, 30, 32};
    private ICamera parent;

    /**
     * Creates the basic camera controler.
     * @param Parent The camera that the controler must control.
     */
    public BasicCameraControl(ICamera Parent)
    {
        parent = Parent;
    }
    public int[] getKeysToWaitFor()
    {
        return keysToWaitFor;
    }

    public void KeyIsDown(int key)
    {
        switch(key)
        {
            case 17:
                parent.moveForward(0.2f);
                break;
            case 31:
                parent.moveBackward(0.2f);
                break;
            case 30:
                parent.moveLeft(0.15f);
                break;
            case 32:
                parent.moveRight(0.15f);
                break;
        }
    }
    public void MouseChangedY(int ammount)
    {
        if(ammount < 0)
        {
            ammount = ammount * (-1);
            parent.LookDown(ammount/4);
        }
        else
        {
            parent.LookUp(ammount / 4);
        }
    }
    public void MouseChangedX(int ammount)
    {
        if(ammount < 0)
        {
            ammount = ammount * (-1);
            parent.LookLeft(ammount/4);
        }
        else
        {
            parent.LookRight(ammount / 4);
        }

    }
}
